
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
Making database connections</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="dwprgugp57.htm">Previous</A>&nbsp;&nbsp;<A HREF="dwprgugp59.htm" >Next</A>
<!-- End Header -->
<A NAME="BGBCHHGF"></A><h1>Making database connections</h1>
<A NAME="TI2337"></A><h4>The connection process</h4>
<A NAME="TI2338"></A><p>The Web ActiveX and Transaction Object controls make database
connections using JDBC. Their Java classes interact with the Java
classes of the database vendor's JDBC interface. The vendor's
classes interact with the database.</p>
<A NAME="TI2339"></A><h4>JDBC driver from a database vendor</h4>
<A NAME="TI2340"></A><p>The classes for the JDBC database driver you plan to use must
be available to the user's browser. If the user does not
have them installed already, you can set up the Web page so that
they are downloaded and installed just as you do for the Web ActiveX.</p>
<A NAME="TI2341"></A><p>To have the JDBC driver classes installed automatically, you
can:<A NAME="TI2342"></A>
<ol>
</li>
<li class=ds>Convert the database
vendor's Java classes into a CAB file. You can use a Microsoft
utility called CABARC to do the conversion. The classes can be in
a ZIP archive or directory tree.</li>
<li class=ds>Add an Object element with a CODEBASE attribute
for the CAB file to the Web page. 
</li>
</ol>
</p>
<A NAME="TI2343"></A><p>The browser downloads the CAB file and adds the classes to
its internal class path. There is no change made to the CLASSPATH
environment variable.</p>
<A NAME="TI2344"></A><p>If you want to use the JDBC driver when you are defining DataWindow objects,
you need to do some additional installation, such as putting the
JDBC driver classes on the system class path. </p>
<A NAME="TI2345"></A><p>For more information, see <i>Connecting to Your Database</i>
 or
the online Help for PowerBuilder.</p>
<A NAME="TI2346"></A><h4>Connection properties</h4>
<A NAME="TI2347"></A><p>The connection information for the Transaction Object or Web
ActiveX is set as Param elements enclosed in the Object element.
Whether you use a separate Transaction object or the internal connection
properties of the Web ActiveX, the connection properties are the
same:</p>
<A NAME="TI2348"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 8-1: Connection properties of the Transaction Object and Web ActiveX
controls</caption>
<tr><th  rowspan="1"  ><A NAME="TI2349"></A>Param name</th>
<th  rowspan="1"  ><A NAME="TI2350"></A>Meaning</th>
<th  rowspan="1"  ><A NAME="TI2351"></A>Typical value</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI2352"></A>LogID</td>
<td  rowspan="1"  ><A NAME="TI2353"></A>The ID needed to log in to the database.</td>
<td  rowspan="1"  ><A NAME="TI2354"></A>dba (default ID for ASA databases)</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI2355"></A>LogPass</td>
<td  rowspan="1"  ><A NAME="TI2356"></A>The password needed to log in to the
database.</td>
<td  rowspan="1"  ><A NAME="TI2357"></A>sql (default password for ASA databases)</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI2358"></A>dbParm</td>
<td  rowspan="1"  ><A NAME="TI2359"></A>A string specifying the Java classes
for the driver and the URL for the database.</td>
<td  rowspan="1"  ><A NAME="TI2360"></A>For the JConnect driver: Driver='com.sybase.jdbc3.jdbc.SybDriver',URL='jdbc:sybase:Tds:199.1.1.1:9999/mydatabase'</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI2361"></A>Lock</td>
<td  rowspan="1"  ><A NAME="TI2362"></A>The isolation level of the connection.</td>
<td  rowspan="1"  ><A NAME="TI2363"></A>Vendor-specific values</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI2364"></A>AutoCommit</td>
<td  rowspan="1"  ><A NAME="TI2365"></A>Whether a commit occurs immediately after
the database is updated.</td>
<td  rowspan="1"  ><A NAME="TI2366"></A>False (default)</td>
</tr>
</table>
<A NAME="TI2367"></A><h4>About dbParm</h4>
<A NAME="TI2368"></A><p>For JDBC drivers, the dbParm property specifies essential
connection information. Its value is a string that contains at least
two values. Those values identify the driver you want to use and
the URL of the database, in a format understood by the driver.</p>
<A NAME="TI2369"></A><p>The format is:<p><PRE>Driver='<i>JDBCclassname</i>',URL='<i>database_url </i>'</PRE></p>
</p>
<A NAME="TI2370"></A><p>To find the class name for Driver and the format of the database
URL, check the documentation from the DBMS vendor.</p>
<A NAME="TI2371"></A><p>For examples of setting these properties in Param elements,
see <A HREF="dwprgugp55.htm#BGBDIHBJ">"Properties and Param elements"</A>.</p>
<A NAME="TI2372"></A><h4>JConnect in the development environment</h4>
<A NAME="TI2373"></A><p>If you want to use JConnect when you define DataWindow objects,
put the Java classes for JConnect on the class path. </p>
<A NAME="TI2374"></A><h2>Connecting and retrieving data</h2>
<A NAME="TI2375"></A><p>To connect and retrieve data, you must write a script. The
script can belong to a Retrieve button, or you can have the retrieval
occur automatically by putting the code in the window's
onLoad script.</p>
<A NAME="TI2376"></A><p>For example, to connect and retrieve data for a Web ActiveX
named <i>dw_1</i>, using a DataWindow Transaction
Object control named <i>trans_1</i>, your
script would be similar to this:<p><PRE> trans_1.Connect( );</PRE><PRE> dw_1.SetTransObject( trans_1 );</PRE><PRE> dw_1.Retrieve( );</PRE></p>
<A NAME="TI2377"></A><p>When you use the internal transaction properties, the Web
ActiveX makes the connection automatically. The script can be simpler,
like this:<p><PRE> dw_1.Retrieve( );</PRE></p>

